﻿using Microsoft.AspNetCore.Http;
using ShoppingCar.carousel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;

namespace ShoppingCar
{
    public class FileImageService : ApplicationService, IFileImageService
    {
        public string UploadFile(IFormFile file)
        {
            string rootdir = AppContext.BaseDirectory.Split(@"\bin\")[0];
            string filename = DateTime.Now.ToString("yyyyMMddHHmmssffff") + System.IO.Path.GetExtension(file.FileName);
            var path = rootdir + @"\tu\" + filename;
            using (System.IO.FileStream fs = System.IO.File.Create(path))
            {
                file.CopyTo(fs);
                fs.Flush();//清空文件流
            }
            return "http://localhost:8010/" + filename;//将能访问新文件的网址回传给前
        }
    }
}
